<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        canvas{
            background-color: red;
        }
    </style>
</head>

<body>
    <canvas width="400" height="400"></canvas>
    <script>
        let myCanvas = document.querySelector('canvas');
        let canCon = myCanvas.getContext("2d");
        function create(row, col) {
            for (var i = 0; i < row; i++) {
                for (var j = 0; j < col; j++) {
                    canCon.fillStyle = 'rgb(' + Math.floor(255 - (255 / row) * i) + ',' +
                        Math.floor(255 - (255 / col) * j) + ',0)';
                    canCon.fillRect(j * 25, i * 25, 25, 25);

                }
            }
        }
        create(10,10)
    </script>
</body>

</html>